/*
given a list of numbers, including big integers of an arbitrary number of
digits, sort it in ascending order
*/

#include <algorithm> // for sort()
#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool customComparator(string a, string b) {
    // handling negative numbers:
    // if only first string is `-ve`
    if (a[0] == '-' && b[0] != '-') {
        return true;
    }

    // if only second string is `-ve`
    if (a[0] != '-' && b[0] == '-') {
        return false;
    }

    // if both are negative
    if (a[0] == '-' && b[0] == '-') {
        if (a.length() == b.length()) {
            return a > b;
        }

        return a.length() > b.length();
    }
    // handling positive numbers:
    if (a.length() == b.length()) {
        return a < b;
    }

    return a.length() < b.length();
}

int main() {
    int noOfNumbers;
    cin >> noOfNumbers;
    vector<string> BigInts;

    for (int i = 0; i < noOfNumbers; ++i) {
        string currentNumber;
        cin >> currentNumber;
        BigInts.push_back(currentNumber);
    }

    sort(BigInts.begin(), BigInts.end(), customComparator);

    for (string num: BigInts) {
        cout << num << endl;
    }

    return 0;
}

/* Sample Input
---------------
26
-111111111111111111
9999999999999999999
21993910491043105540359212
-2132
-12
-43
12999329942
231005004
53995
111
*/

/* Sample Output
----------------


*/
